package com.xdl.flytest.util;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @Auther: 80736
 * @Date: 2018/12/30 18:07
 * @Description:
 */
public class JsonResponseMessage {

    private LinkedHashMap<String, Object> map;

    private ResponseMsg responseMsg;


    public JsonResponseMessage(ResponseMsg msg) {
        map = new LinkedHashMap<>();
        map.put("code", msg.getCode());
        map.put("msg", msg.getMsg());
    }

    public JsonResponseMessage() {
    }

    public ResponseMsg getResponseMsg() {
        return responseMsg;
    }

    public void setResponseMsg(ResponseMsg responseMsg) {
        this.responseMsg = responseMsg;
        if (map == null) {
            map = new LinkedHashMap<>();
        }
        map.put("code", responseMsg.getCode());
        map.put("msg", responseMsg.getMsg());

    }

    public JsonResponseMessage addAttribute(String key, Object value) {
        map.put(key, value);
        return this;
    }

    public Map<String, Object> returned() {
        return map;
    }

    public LinkedHashMap<String, Object> getMap() {
        return map;
    }

    public void setMap(LinkedHashMap<String, Object> map) {
        this.map = map;
    }

}
